# Maintainer: Thore Bödecker <foxxx0@archlinux.org>
# Contributor: Laurent Soest <laurent.soest(at)gmail.com>

pkgname='python-tempora'
_pkgbase="${pkgname//python-/}"
pkgver=5.2.2
pkgrel=2
pkgdesc="Objects and routines pertaining to date and time (tempora)."
arch=('any')
url="https://github.com/jaraco/tempora"
license=('MIT')
depends=('python' 'python-pytz' 'python-jaraco.functools')
makedepends=('python-setuptools' 'python-setuptools-scm' 'python-attrs')
checkdepends=('python-pytest' 'python-pytest-flake8' 'python-pytest-cov'
              'python-pytest-black' 'python-freezegun' 'python-pytest-freezegun'
              'python-pytest-mypy')
source=("${pkgname}-${pkgver}.tar.gz::${url}/archive/v${pkgver}.tar.gz"
        'LICENSE')
sha512sums=('bef8fa0c7815cc18886f3c4ab7573912d6f5a840629a5f753cc53bb82c3111a4ca34424685fc32731e1e8cb2064031411414b0ce31235dca947b5051d65ec773'
            '1106afed483b7258e4ae89c5d9459c3834412b31aac90169725ed62d2ab44f61f6f79e894d4c9e4d8bd99e14530ab778df2187784f0b25eaab86d312fad68944')

# setuptools won't find version from git tag
export SETUPTOOLS_SCM_PRETEND_VERSION="${pkgver}"

build() {
    cd "${srcdir}/${_pkgbase}-${pkgver}"
    python -c 'from setuptools import setup; setup()' build
}

check() {
    cd "${srcdir}/${_pkgbase}-${pkgver}"
    pytest
}

package() {
    cd "${srcdir}/${_pkgbase}-${pkgver}"
    python -c 'from setuptools import setup; setup()' install --root="${pkgdir}" --optimize=1

    # the author has promised to include a LICENSE file in future releases:
    # https://github.com/jaraco/skeleton/issues/1
    # for now the LICENSE file has been taken from:
    # https://github.com/jaraco/skeleton/blob/skeleton/LICENSE
    install -D -m644 "${srcdir}/LICENSE" "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
}
